package com.innovation.sys.common.utils;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;

public class ResponseUtils {
	
	private static Logger logger = LoggerFactory.getLogger(ResponseUtils.class);
	
	public static void writeData(HttpServletRequest request, HttpServletResponse response, Object data) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = null;
		try {
			out = response.getWriter();
			out.write(JSON.toJSONString(data));
		} catch (IOException e) {
			logger.error("error:{}", e);
		}
	}

}
